how-to get current hostname in javascript
window.location.host or document.location.host : you’ll get sub.domain.com:8080 or sub.domain.com:80
window.location.hostname or document.location.hostname: you’ll get sub.domain.com
window.location.protocol or document.location.protocol: you’ll get http:
window.location.port or document.location.port: you’ll get 8080 or 80
window.location.origin or document.location.origin: you’ll get http://sub.domain.com *